//TableHead.js
import React, { Component } from 'react';

import ResizeDivClass from "./resizeDivClass";
export default class TableHeadView extends Component {
    constructor(props) {
        super(props)
        this.state = {

        }
        //this.display = this.determineDisplay({ x: props.x, y: props.y }, props.value)
        this.timer = 0
        this.delay = 200
        this.prevent = false
    }

    handleCellMouseDown=(e,i)=>{
       // this.props.handleCellMouseDown(e,i);
    }

    // 根据数值转换为大写字母表
     IntToLbl(index){
        var b = (index - 1).toString(26).toUpperCase();
        var c = [];
        for (var i = 0; i < b.length; i++) {
            var x = b.charCodeAt(i);
            if (i <= 0 && b.length > 1)
                x = x - 1;
            if (x <= 57)
                c.push(String.fromCharCode(x - 48 + 65));
            else
                c.push(String.fromCharCode(x + 10));
        }
        return c.join("");
    }



    render() {
        let c = this.props.colNum;  //列数
        let colWidths=this.props.colWidths;
        let tableHeadCells = [];
        //for (var i = 0; i < c; i++) {
        for (var i = 1; i < c; i++) {
            let p=i;
            tableHeadCells.push(<th  key={"#tableHeadCells" + i} className="top_td"  style={{width: ''+colWidths[i]+'pt'}} >
                <div  className="tabHeadDiv">
                    <span></span>

                 <span>{this.IntToLbl(i)}</span>
                   <ResizeDivClass no={i}
                                   handleCellMouseDown={(e)=>this.handleCellMouseDown(e,p)}
                   />
                </div>
            </th>);
        }



  return (
      <tr key="tableHeadKey"
          // onMouseUp={this.onMouseUp}
      >
          <th  key="tableHead00Key"   ></th>{tableHeadCells}</tr>
        )
    }
}
